package com.diaohw.module.system.obj.tables;

import com.diaohw.platform.framework.db.flex.obj.tables.BaseTableDef;
import com.mybatisflex.core.query.QueryColumn;

import java.io.Serial;

/**
 * 部门 表定义层。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
public class DepartmentDef extends BaseTableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 部门
     */
    public static final DepartmentDef DEPARTMENT = new DepartmentDef();

    /**
     * 状态;0：禁用，1：启用
     */
    public final QueryColumn STATE = new QueryColumn(this, "STATE");

    /**
     * 备注
     */
    public final QueryColumn REMARK = new QueryColumn(this, "REMARK");

    /**
     * 父级ID
     */
    public final QueryColumn PARENT_ID = new QueryColumn(this, "PARENT_ID");

    /**
     * 部门名称
     */
    public final QueryColumn DEPARTMENT_NAME = new QueryColumn(this, "DEPARTMENT_NAME");


    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{PARENT_ID, DEPARTMENT_NAME, STATE, REMARK};

    public DepartmentDef() {
        super("", "DEPARTMENT");
    }

    private DepartmentDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public DepartmentDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new DepartmentDef("", "DEPARTMENT", alias));
    }

}
